package io.renren.modules.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demo.dao.ShareUserDao;
import io.renren.modules.demo.dto.ShareUserDTO;
import io.renren.modules.demo.entity.ShareUserEntity;
import io.renren.modules.demo.service.ShareUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2021-05-24
 */
@Service
public class ShareUserServiceImpl extends CrudServiceImpl<ShareUserDao, ShareUserEntity, ShareUserDTO> implements ShareUserService {

    @Autowired
    private ShareUserDao shareUserDao;

    @Override
    public QueryWrapper<ShareUserEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<ShareUserEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<ShareUserDTO> selectDimUserByName(String name) {
        return shareUserDao.selectDimUserByName("%"+name+"%");
    }
}